<?php

include("load-settings.php");

$summoner = "scrubakins";
$region = "na";

require_once("unirest/lib/Unirest.php");

$newresponse = Unirest::get(
  "https://teemojson.p.mashape.com/player/".$region."/".str_replace(" ", "", $summoner)."/recent_games",
  array(
	"X-Mashape-Authorization" => "l5ekV2qGSVYpEWLviXHg4A6oRHRtqNBa"
  ),
  null
);

//$decode = json_decode($newresponse->raw_body)->data;

//echo $decode; die;

$beginning_lp = 0;
$newwins = 0;
$newlosses = 0;
echo "<pre>"; var_dump($newresponse); echo "</pre>"; die;
$x = 0;
while(isset($decode->array[$x]))
{
//$newdecode = json_decode($newresponse->raw_body)->data->summonerLeagues->array[0]->entries->array;
$newdecode = $decode->array[$x]->entries->array;
//echo "<pre>"; var_dump($newdecode); echo "</pre>"; die;

$y = 0;
while(isset($newdecode[$y]))
{
	if($newdecode[$y]->playerOrTeamName == $summoner)
	{
		$newwins = $newdecode[$y]->wins;
		$newlosses = $newdecode[$y]->losses;
		$beginning_lp = $newdecode[$y]->leaguePoints;
		break;
	}

	$y++;
}
$x++;
}

$beginning_stats = $newwins." wins, ".$newlosses." losses";

echo $beginning_stats;
echo $beginning_lp;

?>